var a = getApp();

Page({
    data: {
        recordsList: [],
        activeName: "team",
        api: "plugin.team-dividend.api.results.getList",
        is_show: !1,
        isLoadMore: !0,
        page: 1,
        total_page: 0
    },
    onLoad: function(a) {
        this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {},
    handleChange: function(a) {
        this.data.activeName = a.detail.name, "people" === this.data.activeName ? this.data.api = "plugin.team-dividend.api.results.getMyOrder" : this.data.api = "plugin.team-dividend.api.results.getList", 
        this.initData(), this.getData();
    },
    initData: function() {
        this.setData({
            recordsList: [],
            page: 1,
            total_page: 0,
            isLoadMore: !0
        });
    },
    getData: function() {
        var t = this, e = a.getNetAddresss(this.data.api);
        a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 === e.result ? (t.setData({
                    isLoadMore: !0
                }), "people" === t.data.activeName ? t.setData({
                    recordsList: e.data.data,
                    total_page: e.data.last_page
                }) : t.setData({
                    is_show: e.data.is_show,
                    recordsList: e.data.data.data,
                    total_page: e.data.data.last_page
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(a) {
                console.log(a);
            }
        });
    },
    getMoreData: function() {
        var t = this, e = a.getNetAddresss(this.data.api);
        this.data.page >= this.data.total_page ? this.setData({
            isLoadMore: !1
        }) : (this.setData({
            page: this.data.page + 1
        }), e += "&page=" + this.data.page, a._getNetWork({
            url: e,
            success: function(a) {
                if (1 == a.data.result) {
                    var e = a.data.data.data;
                    "people" === t.data.activeName ? t.setData({
                        isLoadMore: !0,
                        recordsList: t.data.recordsList.concat(e)
                    }) : t.setData({
                        isLoadMore: !0,
                        recordsList: t.data.recordsList.concat(e.data)
                    });
                } else t.setData({
                    page: t.data.page - 1,
                    isLoadMore: !1
                });
            },
            fail: function(a) {
                console.log(a);
            }
        }));
    }
});